struct Solution;

impl Solution {
  pub fn max_increase_keeping_skyline(grid: Vec<Vec<i32>>) -> i32 {
    let mut row_high = vec![0; grid.len()];
    let mut col_high = vec![0; grid.len()];
    let mut ret = 0;
    for (y, row) in grid.iter().enumerate() {
      for (x,elm) in row.iter().enumerate() {
        if elm > &row_high[x] {
          row_high[x] = *elm;
        }
        if elm > &col_high[y] {
          col_high[y] = *elm;
        }
      }
    }
    for (y, row) in grid.iter().enumerate() {
      for (x,elm) in row.iter().enumerate() {
        let target = if row_high[x] > col_high[y] { col_high[y] } else { row_high[x] };
        ret += target - elm; 
      }
    }    
    return ret;  
  }
}

fn main() {
  
}